import 'package:dio/dio.dart';
import 'package:get/get.dart';
import 'package:get/get_state_manager/src/simple/get_controllers.dart';

import '../../../../../bean/KeyValueBean.dart';

class EmployerPage_workTypeSelectController extends GetxController {
  RxList<KeyValueBean> list_gz = <KeyValueBean>[].obs;
  RxList<KeyValueBean> list_xz = <KeyValueBean>[].obs;

  EmployerPage_workTypeSelectController() {
    initData();
  }

  void initData() {
    list_gz.add(KeyValueBean.keyValue(key: "1", value: "管家", ui_select_view_data: 0));
    // list_gz.add(KeyValueBean("2", "家员私助", 0));
    // list_gz.add(KeyValueBean("3", "家员整洁", 0));
    // list_gz.add(KeyValueBean("4", "家员私厨", 0));
    // list_gz.add(KeyValueBean("5", "家员私医", 0));
    // list_gz.add(KeyValueBean("6", "家员司保", 0));
    // list_gz.add(KeyValueBean("7", "家员老伴", 0));
    // list_gz.add(KeyValueBean("8", "家员母婴", 0));
    // list_gz.add(KeyValueBean("9", "家员儿伴", 0));
    // list_gz.add(KeyValueBean("10", "家员宠伴", 0));
    // list_gz.add(KeyValueBean("11", "家员园丁", 0));

    list_xz.add(KeyValueBean.keyValue(key:"0", value: "面议", ui_select_view_data: 0));
    // list_xz.add(KeyValueBean("1", "6-12W", 0));
    // list_xz.add(KeyValueBean("2", "12-18W", 0));
    // list_xz.add(KeyValueBean("3", "18-24W", 0));
    // list_xz.add(KeyValueBean("4", "24-36W", 0));
    // list_xz.add(KeyValueBean("5", "36-50W", 0));
    // list_xz.add(KeyValueBean("6", "50W-100W", 0));
    // list_xz.add(KeyValueBean("7", "100W以上", 0));
  }

  void clearData() {
    list_gz.forEach((v) {
      v.ui_select_view_data = 0;
    });
    list_xz.forEach((v) {
      v.ui_select_view_data = 0;
    });
    list_gz.refresh();
    list_xz.refresh();
  }

  Map<String, List<KeyValueBean>> select() {
    Map<String, List<KeyValueBean>> map = {};
    List<KeyValueBean> selectedList1 =
    list_gz.where((v) => v.ui_select_view_data == 1).toList();
    List<KeyValueBean> selectedList2 =
    list_xz.where((v) => v.ui_select_view_data == 1).toList();
    if (selectedList1.isNotEmpty && selectedList2.length > 0) {
      map["list_gz"] = selectedList1;
    }

    if (selectedList2.isNotEmpty && selectedList2.length > 0) {
      map["list_xz"] = selectedList2;
    }

    return map;
  }
}
